

local Field = import("./Field.lua");
local Label = commonlib.inherit(Field);

function Label:Init(block, opt)
    Label._super.Init(self, block, opt);

    self:SetValue(opt.value or "");
    self:SetText(self:GetValue());
    self:SetType(self:GetType() or "field_label");

    return self;
end

function Label:Render()
    local leftUnitCount, topUnitCount = self:GetLeftTopUnitCount();
    local widthUnitCount, heightUnitCount = self:GetWidthHeightUnitCount();
    -- print(leftUnitCount, topUnitCount, widthUnitCount, heightUnitCount)
    self:DrawText(self:GetText(), widthUnitCount, heightUnitCount, leftUnitCount, topUnitCount, nil, 0xffffffff);
end

function Label:UpdateWidthHeightUnitCount()
    return self:GetTextWidthUnitCount(self:GetText()), self.FIELD_TEXT_HEIGHT_UNIT_COUNT;
end

function Label:SaveToXmlNode()
    return nil;
end

function Label:LoadFromXmlNode(xmlNode)
end

function Label:IsCanEdit()
    return false;
end

return Label;